package com.ichir.projects.uiframework.tests.mocks;

import java.awt.BorderLayout;
import java.util.Map;

import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import com.ichir.projects.uiflow.AbstractUiView;
import com.ichir.projects.uiflow.ApplicationContext;

/**
 * 
 * @author mahieddine_ichir
 */
public class ProgressView extends AbstractUiView {

	private JDialog dialog;
	
	@Override
	public void initializeView(final ApplicationContext context, Map<String, Object> attributes) {
		System.out.println(">> initialize progress view ...");
		dialog = new JDialog();
		dialog.setSize(200, 50);
		dialog.setContentPane(new JPanel(new BorderLayout(5, 5)));
		dialog.setUndecorated(true);
		dialog.setAlwaysOnTop(true);

		JLabel comp = new JLabel("Progess ...");
		comp.setHorizontalAlignment(SwingConstants.CENTER);
		dialog.add(comp);
		dialog.setLocationRelativeTo(null);
	}

	@Override
	public void refreshView(ApplicationContext context, Map<String, Object> attributes) {
		System.out.println(">> refresh progress");
	}

	@Override
	public void showView(ApplicationContext context, Map<String, Object> attributes) {
		System.out.println(">> show progress");
		dialog.setVisible(true);
	}

	@Override
	public void disposeView(ApplicationContext context, Map<String, Object> attributes) {
		System.out.println(">> dispose progress");
		dialog.dispose();
	}
}
